package cn.edu.sjtu.dfa;

public class PairMove extends Move {
	private DataContainer endHigh;
	private DataContainer startHigh;
	
	public PairMove (DataContainer v1, DataContainer v2, DataContainer v3, DataContainer v4){
		super(v1,v3);
		this.endHigh = v2;
		this.startHigh = v4;
	}
	
	public DataContainer getEndHigh() {
		return this.endHigh;
	}
	
	public DataContainer getStartHigh() {
		return this.startHigh;
	}
	
	@Override
	public String toString() {
		String ss1 = "", ss2 = "", es1 = "", es2 = "";
		if (getStart() instanceof Register) {
			ss1 = "v" + ((Register)getStart()).getRegister();
		} else if (getStart() instanceof ArrayValue) {
			ss1 = ((ArrayValue)getStart()).getArrayRef() + "[" + ((ArrayValue)getStart()).getIndex() + "]";
		} else if (getStart() instanceof ObjectValue) {
			ss1 = ((ObjectValue)getStart()).getArrayRef() + "." + ((ObjectValue)getStart()).getIndex();
		} else {
			ss1 = getStart().getValue().toString();
		}
		if (startHigh instanceof Register) {
			ss2 = "v" + ((Register)startHigh).getRegister();
		} else if (startHigh instanceof ArrayValue) {
			ss2 = ((ArrayValue)startHigh).getArrayRef() + "[" + ((ArrayValue)startHigh).getIndex() + "]";
		} else if (startHigh instanceof ObjectValue) {
			ss2 = ((ObjectValue)startHigh).getArrayRef() + "." + ((ObjectValue)startHigh).getIndex();
		} else {
			ss2 = startHigh.getValue().toString();
		}
		if (getEnd() instanceof Register) {
			es1 = "v" + ((Register)getEnd()).getRegister();
		} else if (getEnd() instanceof ArrayValue) {
			es1 = ((ArrayValue)getEnd()).getArrayRef() + "[" + ((ArrayValue)getEnd()).getIndex() + "]";
		} else if (getEnd() instanceof ObjectValue) {
			es1 = ((ObjectValue)getEnd()).getArrayRef() + "." + ((ObjectValue)getEnd()).getIndex();
		} else {
			es1 = getEnd().getValue().toString();
		}
		if (endHigh instanceof Register) {
			es2 = "v" + ((Register)endHigh).getRegister();
		} else if (endHigh instanceof ArrayValue) {
			es2 = ((ArrayValue)endHigh).getArrayRef() + "[" + ((ArrayValue)endHigh).getIndex() + "]";
		} else if (endHigh instanceof ObjectValue) {
			es2 = ((ObjectValue)endHigh).getArrayRef() + "." + ((ObjectValue)endHigh).getIndex();
		} else {
			es2 = endHigh.getValue().toString();
		}
		return "Move " + ss1 + " " + ss2 + " to " + es1 + " " + es2;
	}

}
